   package com.javalong.affairs.module.notifything.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.EditText;

import com.javalong.affairs.R;
import com.javalong.affairs.base.activity.UIHandlerActivity;
import com.javalong.affairs.base.constant.BundleKey;
import com.javalong.affairs.base.ui.TopTitle;
import com.javalong.affairs.base.ui.TopTitle.OnLeftDrawableClick;
import com.javalong.affairs.base.ui.TopTitle.OnRightTextClick;
import com.javalong.affairs.base.utils.StringUtils;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ContentView;
import com.lidroid.xutils.view.annotation.ViewInject;

@ContentView(R.layout.activity_editcontent)
public class EditContentActivity extends UIHandlerActivity {
	@ViewInject(R.id.ui_toptitle)
	private TopTitle topTitle;
	@ViewInject(R.id.et_content)
	private EditText et_content;
	public String editConetnt;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ViewUtils.inject(this);
		initData();
		initUI();
	}

	private void initData() {
		editConetnt = getIntent().getStringExtra(BundleKey.EDITCONTENT);
		if (!StringUtils.isEmpty(editConetnt)) {
			et_content.setText(editConetnt);
		}
	}

	private void initUI() {
		topTitle.setOnLeftDrawableClick(new OnLeftDrawableClick() {

			@Override
			public void leftClick() {
				finish();
			}
		});
		topTitle.setOnRightTextClick(new OnRightTextClick() {
			@Override
			public void rightTextClick() {
				finishEdit();
			}
		});
	}

	private void finishEdit() {
		Intent intent = new Intent();
		intent.putExtra(BundleKey.EDITCONTENT, et_content.getText().toString());
		setResult(RESULT_OK, intent);
		finish();
	}
}
